const util = require("../../utils/util")
const images = require("../../images/bank/bank-sel/base64_images")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    card:{}
  },
  handleCardNum(num){
    return num.slice(-4);
  },
  toUpdateBank(){
    let that = this
    wx.navigateTo({
      url:"../updateBank/updateBank?openBank="+that.data.card.openBank+
        "&cardholder="+that.data.card.cardholder+
        "&bankCard="+that.data.card.bankCard
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // let names = []
    // let list = []
    // Object.keys(images.banks).forEach((value,index) => {
    //   console.log(index,images.banks[value].name)
    //   names[index] = images.banks[value].name
    //   list[index] = value
    // });
    // console.log(list,names)
    // this.setData({banks:names,list:list})
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let that = this
    util.post({
      url: "https://groomtea.icebartech.com/api/miniApp/salesman/bankDetail",
      success: (res) => {
        console.log(res.data.bussData)
        that.setData({
          card: res.data.bussData,
          cardName: images.banks['bank'+res.data.bussData.openBank].name,
          cardImg: images.banks['bank'+res.data.bussData.openBank].img,
          num: that.handleCardNum(res.data.bussData.bankCard)
        })
      }
    })

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})